require 'watir'
include Watir
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/testcase'
require 'watir/contrib/enabled_popup'
class TC_blogsFrontEnd < Test::Unit::TestCase

    def test_01_AnonymousBlogFunctioningDisabled_Blogs
    $ie.goto($UniVar)      


    $ie.wait()
    $ie.goto($UniVar + '/controlpanel/BlogAdmin/sectionedit.aspx')
    $ie.wait()
    $ie.text_field(:index, 1).set('watir blog')
    $ie.text_field(:index, 2).set('watirblog')
    $ie.text_field(:index, 3).set($ADMIN)
    $ie.link(:text, 'Save').click          



    $ie.goto($UniVar + '/ControlPanel/Blogs/posteditor.aspx?SelectedNavItem=NewPost')
    $ie.wait()
    $ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostSubject/).set('watir blog')
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + $Description + "')")
    $ie.wait()
    $ie.link(:text, 'Publish').click 

  

    $ie.goto($UniVar)
    $ie.wait()
    $ie.link(:text, 'Blogs').click
    $ie.link(:text, $ADMIN).click
		assert($ie.contains_text('Password'))
			$ie.link(:text, 'Blogs').click
			$ie.link(:text, 'watir blog').click	
      assert($ie.contains_text('some body'))

    

    $ie.goto($UniVar + '/controlpanel/BlogAdmin/Blogs.aspx')
    $ie.wait()
    $ie.link(:text, 'Delete').click_no_wait
    hwnd = $ie.enabled_popup(5)
      if(hwnd)
        w = WinClicker.new
        w.clickWindowsButton_hwnd(hwnd, "OK")
      end

    end
end